/**
 * Project Name:Android_Car_Example
 * File Name:PositionEntity.java
 * Package Name:com.amap.api.car.example
 * Date:2015年4月3日上午9:50:28
 */

package com.yxhl.zoume.core.func.map.info;

import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.MarkerOptions;
import com.yxhl.zoume.R;

import java.io.Serializable;

/**
 * ClassName:PositionEntity <br/>
 * Function: 封装的关于位置的实体 <br/>
 * Date: 2015年4月3日 上午9:50:28 <br/>
 *
 * @author yiyi.qi
 * @see
 * @since JDK 1.6
 */
public class PoiInfo implements Serializable {

    public double latitue;

    public double longitude;

    public String address;

    public String addressName;

    public String city;

    public String cityCode;
    public String aCode;
    public int iconId;

    public PoiInfo() {
    }

    public PoiInfo(double latitude, double longtitude, String addressName, String address, String city, String cityCode, String aCode) {
        this.latitue = latitude;
        this.longitude = longtitude;
        this.address = address;
        this.addressName = addressName;
        this.city = city;
        this.cityCode = cityCode;
        this.aCode = aCode;
    }

    public PoiInfo(double latitude, double longtitude, String addressName, String address) {
        this(latitude, longtitude, addressName, address, "", "", "");
    }

    public String getaCode() {
        return aCode;
    }

    public void setaCode(String aCode) {
        this.aCode = aCode;
    }

    public double getLatitue() {
        return latitue;
    }

    public void setLatitue(double latitue) {
        this.latitue = latitue;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    /**
     * 设置位置信息
     *
     * @return
     */
    public PoiInfo setLat(double lat) {
        latitue = lat;
        return this;
    }

    public PoiInfo setLon(double lon) {
        longitude = lon;
        return this;
    }

    /**
     * 设置图片资源ID
     *
     * @return
     */
    public PoiInfo setIconId(int id) {
        iconId = id;
        return this;
    }

    /**
     * 创建MarkerOptions
     *
     * @return
     */
    public MarkerOptions createMarkerOptions() {
        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.setGps(true);
        markerOptions.title(address);
        markerOptions.anchor(0.5f, 0.5f);
        if (0 == iconId) {
            BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory
                    .fromResource(R.drawable.icon_car);
            markerOptions.icon(bitmapDescriptor);
        } else {
            BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory
                    .fromResource(iconId);
            markerOptions.icon(bitmapDescriptor);
        }
        markerOptions.position(new LatLng(latitue, longitude));
        return markerOptions;
    }


    @Override
    public String toString() {
        return "PoiInfo{" +
                "latitue=" + latitue +
                ", longitude=" + longitude +
                ", address='" + address + '\'' +
                ", addressName='" + addressName + '\'' +
                ", city='" + city + '\'' +
                ", cityCode='" + cityCode + '\'' +
                ", aCode='" + aCode + '\'' +
                ", iconId=" + iconId +
                '}';
    }
}
